package com.itheima.pattern.responsibility;

public abstract class Handler {
    protected static final int NUM_ONE=3;
    protected static final int NUM_THREE=7;
    protected static final int NUM_SEVEN=15;

    //该领导处理的天数区间
    private int numStart;
    private int numEnd;
    private Handler nextHandler;

    public Handler(int numStart, int numEnd) {
        this.numStart = numStart;
        this.numEnd = numEnd;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    //各级处理请假条的方法
    public abstract void handleLeave(LeaveRequest leave);

    public final void submit(LeaveRequest leave){
        if(leave.getNum()>=this.numStart && leave.getNum()<this.numEnd){
            //该领导进行审查
            handleLeave(leave);
        }else if(this.nextHandler!=null && leave.getNum()>=this.numEnd){
            this.nextHandler.submit(leave);
        }else {
            System.out.println("经过公司审批：同意，永远不要来了");
        }

    }


}
